package StudyCode.summary.mycollection;

import java.util.Iterator;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReturnsTheNumberOfElementsTheIterableContains {
	public static <T> int count(Iterable<T> iterable) {
		int count = 0;

		if (iterable != null) {
			Iterator<T> iter = iterable.iterator();
			while (iter.hasNext()) {
				iter.next();
				count++;
			}
		}

		return count;
	}
}
